<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
function showResult(str) {
 if (str.length==0) {
   document.getElementById("livesearch").innerHTML="";
    document.getElementById("livesearch").style.border="0px";
   return;
  }
 if (window.XMLHttpRequest) {
    //   IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
  }else {  //   IE6, IE5
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 xmlhttp.onreadystatechange=function() {
   if (this.readyState==4 && this.status==200) {
    document.getElementById("livesearch").innerHTML=this.responseText;
    $(".search_result").fadeIn();
      document.getElementById("livesearch").style.border="1px solid #A5ACB2";
    }
  }
 xmlhttp.open("GET","livesearch.php?q="+str,true);
 xmlhttp.send();

}

$(function(){
  $(".who").val('');  
$(".search_result").hover(function(){
    $(".who").blur(); //   input
})
    
//   ,        input
$("#livesearch").on("click", "li", function(){
    //alert($(this).text());
    s_user = $(this).text();
    //$(".who").val(s_user).attr('disabled', 'disabled'); // input,  
    $(".who").val(s_user); // input,  
    $(".search_result").fadeOut();
})
$(document).mouseup(function (e){ //    -
		var form = $(".searchform"); //   ID 
		if (!form.is(e.target) //       
		    && form.has(e.target).length === 0) { //      
			$(".search_result").fadeOut(); //  
		}
	});


});


function checkformufinforum(form)
{
  for (var i = 0; i < form.elements.length; i++)
  if (form.elements[i].value == '')
{
  alert ('    !');
  return false;
}};  


</script>



<form class="searchform" id="searchform" onsubmit="return checkformufinforum(this)"  method="post">
<input class="who" name="text" type="text" size="30" onkeyup="showResult(this.value)" placeholder=" : , ">
<button id="butsearch" class="submit-type-ajax search_result_input" type="button" form="searchform">  </button>
<ul class="search_result" id="livesearch"></ul>
</form>




















<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
function showResult(str) {
 if (str.length==0) {
   document.getElementById("livesearch").innerHTML="";
    document.getElementById("livesearch").style.border="0px";
   return;
  }
 if (window.XMLHttpRequest) {
    //   IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
  }else {  //   IE6, IE5
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 xmlhttp.onreadystatechange=function() {
   if (this.readyState==4 && this.status==200) {
    document.getElementById("livesearch").innerHTML=this.responseText;
    $(".search_result").fadeIn();
      document.getElementById("livesearch").style.border="1px solid #A5ACB2";
    }
  }
 xmlhttp.open("GET","livesearch.php?q="+str,true);
 xmlhttp.send();

}

$(function(){
    $('#who').append('<ul class="search_result" id="livesearch"></ul>');
    $("[name='text']").attr('autocomplete', 'off' );
    //$("form").attr('action', 'https://connectdom.ru/jet-popup/search-prov-list?text=20' );
    $("[name='text']").keydown(function(event){
        if(event.keyCode == 13) {event.preventDefault();
        return false;      }
   });

  $("[name='text']").on("keyup", function(){showResult(this.value)});
  $("[name='text']").val('');  
$(".search_result").hover(function(){
    $("[name='text']").blur(); //   input
})
    
//   ,        input
$("#livesearch").on("click", "li", function(){
    //alert($(this).text());
    s_user = $(this).text();
    //$(".who").val(s_user).attr('disabled', 'disabled'); // input,  
    $("[name='text']").val(s_user); // input,  
    $(".search_result").fadeOut();
})
$(document).mouseup(function (e){ //    -
		var form = $(".searchform"); //   ID 
		if (!form.is(e.target) //       
		    && form.has(e.target).length === 0) { //      
			$(".search_result").fadeOut(); //  
		}
	});


});


function checkformufinforum(form)
{
  for (var i = 0; i < form.elements.length; i++)
  if (form.elements[i].value == '')
{
  alert ('    !');
  return false;
}};  


</script>

